package me.xplabs.gemo 
{
	/**
	 * http://www.xplabs.me/
	 * @author xiaohan
	 */
	public class Point3D 
	{
		public var x:Number;
		public var y:Number;
		public var z:Number;
		public function Point3D(x:Number = 0, y:Number = 0, z:Number = 0)
		{
			this.x = x;
			this.y = y;
			this.z = z;
		}
		public function distance(pt:Point3D):Number
		{
			return Math.sqrt((pt.x - x) * (pt.x - x) + (pt.y - y) * (pt.y - y) + (pt.z - z) * (pt.z - z));
		}
		public function clone():Point3D
		{
			return new Point3D(x, y, z);
		}
		public function offsetPos(pt:Point3D):void
		{
			x += pt.x;
			y += pt.y;
			z += pt.z;
		}
		public function offset(dx:Number = 0, dy:Number = 0, dz:Number = 0):void
		{
			x += dx;
			y += dy;
			z += dz;
		}
		public function toString():String
		{
			return "(x=" + x + ",y=" + y + ",z=" + z + ")";
		}
		
		public function setPos(pt:Point3D):void 
		{
			this.x = pt.x;
			this.y = pt.y;
			this.z = pt.z;
		}
		
		public function setXYZ(x:Number = 0, y:Number = 0, z:Number = 0):void 
		{
			this.x = x;
			this.y = y;
			this.z = z;
		}
	}
}